Skip to content

Change Ambiguous Import error in Typer to case class #2362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 8, 2017

Conversation

ennru
Copy link
Contributor

@ennru ennru commented May 3, 2017

Another more structured error message with hopefully helpful explanations.

@odersky I tried to trigger error(em"reference to $name is ambiguous; it is imported twice ... in Typer.scala:206, but the existing tests all end up in the error detection I now changed. Do you know of an example for that path?

Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the error message in Typer.scala:206 is only triggered when we import something twice under the same name.

The changes in this PR look good. Thank you!

val msg =
s"""|reference to `${hl"$name"}` is ambiguous
|it is both ${bindingString(newPrec, ctx)}
|and ${bindingString(prevPrec, prevCtx, " subsequently")}""".stripMargin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use i""" instead of s""" and drop the .stripMargin here.

val kind = "Reference"

val explanation =
hl"""|The compiler can't decide which of the possible choices you
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need better integration of formatters. It seems non-sensical that we either get explanations of duplicated values (in ex) or syntax highlighting (in hl) but not both. That's just a side remark, intended for a future PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, the current formatters don't compose well. @felixmulder and I discussed the need automated line wrapping as well.

@felixmulder felixmulder merged commit 5093126 into scala:master May 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants